/*****************************************************************************
 * macroblock.h: macroblock encoding
 *****************************************************************************
 * Copyright (C) 2003-2010 zmvc project
 *
 * Authors: Loren Merritt <lorenm@u.washington.edu>
 *          Laurent Aimar <fenrir@via.ecp.fr>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
 *
 * This program is also available under a commercial proprietary license.
 * For more information, contact us at licensing@zmvc.com.
 *****************************************************************************/

#ifndef Zmvc_ENCODER_MACROBLOCK_H
#define Zmvc_ENCODER_MACROBLOCK_H

#include "common/macroblock.h"

extern const int zmvc_lambda2_tab[QP_MAX_MAX+1];
extern const uint16_t zmvc_lambda_tab[QP_MAX_MAX+1];

void zmvc_rdo_init( void );

int zmvc_macroblock_probe_skip( zmvc_t *h, int b_bidir );

#define zmvc_macroblock_probe_pskip( h )\
    zmvc_macroblock_probe_skip( h, 0 )
#define zmvc_macroblock_probe_bskip( h )\
    zmvc_macroblock_probe_skip( h, 1 )

void zmvc_predict_lossless_8x8_chroma( zmvc_t *h, int i_mode );
void zmvc_predict_lossless_4x4( zmvc_t *h, pixel *p_dst, int idx, int i_mode );
void zmvc_predict_lossless_8x8( zmvc_t *h, pixel *p_dst, int idx, int i_mode, pixel edge[33] );
void zmvc_predict_lossless_16x16( zmvc_t *h, int i_mode );

void zmvc_macroblock_encode      ( zmvc_t *h );
void zmvc_macroblock_write_cabac ( zmvc_t *h, zmvc_cabac_t *cb );
void zmvc_macroblock_write_cavlc ( zmvc_t *h );

void zmvc_macroblock_encode_p8x8( zmvc_t *h, int i8 );
void zmvc_macroblock_encode_p4x4( zmvc_t *h, int i4 );
void zmvc_mb_encode_i4x4( zmvc_t *h, int idx, int i_qp );
void zmvc_mb_encode_i8x8( zmvc_t *h, int idx, int i_qp );
void zmvc_mb_encode_8x8_chroma( zmvc_t *h, int b_inter, int i_qp );

void zmvc_cabac_mb_skip( zmvc_t *h, int b_skip );

int zmvc_quant_dc_trellis( zmvc_t *h, dctcoef *dct, int i_quant_cat,
                             int i_qp, int ctx_block_cat, int b_intra, int b_chroma );
int zmvc_quant_4x4_trellis( zmvc_t *h, dctcoef *dct, int i_quant_cat,
                             int i_qp, int ctx_block_cat, int b_intra, int b_chroma, int idx );
int zmvc_quant_8x8_trellis( zmvc_t *h, dctcoef *dct, int i_quant_cat,
                             int i_qp, int b_intra, int idx );

void zmvc_noise_reduction_update( zmvc_t *h );

#endif

